
package com.tiny_wind.tiny_wind_diary.controller;

import org.springframework.web.bind.annotation.ModelAttribute;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


public class BaseController {
	// 这些对象何以直接被子类使用
	protected HttpServletRequest request;
	protected HttpServletResponse response;
	protected HttpSession session;

	@ModelAttribute
	public void setReqAndRes(HttpServletRequest req, HttpServletResponse res) {
		this.request = req;
		this.response = res;
		this.session = req.getSession();
	}
	
	public Integer getUserId() {
		return (Integer)this.request.getAttribute("userId");
	}
}